#include <iostream>
#include <memory>
using namespace std;


class Person
{
public:
    Person()
    {
        cout << "Person()" << endl;
    }

    ~Person()
    {
        cout << "~Person()" << endl;
    }
public:
    void run()
    {
        cout << "Person run()" << endl;
    }
private:
    int m_age;
    char* m_name;
};

template<typename Item>
class SmartPtr
{
public:
    SmartPtr(const Item * obj)
    {
        cout << "SmartPtr()" << endl;
        ptr = obj;
    }

    ~SmartPtr()
    {
        cout << "~SmartPtr()" << endl;
        delete ptr;
    }

    Item* operator->()
    {
        return ptr;
    }
private:
    Item * ptr;
};


int main()
{
    // {
    //     Person * person = new Person; 

    //     delete person;
    // }
    
    // {
    //     auto_ptr<Person> p1(new Person);//p1 = new Person
    //     // shared_ptr<Person> p1(new Person);
    //     p1->run();

            // shared_ptr<Person> p1(new Person);
    // }

    // SmartPtr<Person> p(new Person);
    // p->run();

    {
        shared_ptr<Person> p1(new Person);
        p1->run();

        shared_ptr<Person[]> p2(new Person[3]{});
    }
    
    return 0;
}